<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <link rel="stylesheet" href="/../static/layui/css/layui.css">
    <style>
        table {
            margin: auto;
            border: 1px solid #bfbce2;
            margin-top: 50px;

        }

        tr {
            text-align: center;
        }

        th {
            height: 50px;
            background-color: #dcd9fa;
            border: 1px solid #bfbce2;
        }

        td {
            width: 100px;
            height: 50px;
            border: 1px solid #bfbce2;
        }
        a{
            border-bottom: 1px solid #bfbce2;
        }
    </style>
</head>
<body>
    <div class="container">
        <table cellspacing="0" cellpadding="0">
            <tr>
                <th>问卷Id</th>
                <th>创建者</th>
                <th>主题</th>
                <th>说明</th>
                <th>是否删除</th>
                <th>问题详情</th>
                <th>操作</th>
            </tr>
            {% for item in survey %}
            <tr>
                <td>{{item.id}}</td>
                <td>{{item.name}}</td>
                <td style="width: 300px;">{{item.surveyTheme}}</td>
                <td style="width: 300px;">{{item.surveyState}}</td>
                <td>{{item.isDeletelabe}}</td>
                <td><a href="/root/unpublishQuestion/{{item.id}}">详情</a></td>
                <td><a onclick="remove('{{item.id}}')">删除</a></td>
            </tr>
            {% endfor %}
        </table>
    </div>

    <script src="/../static/js/jquery-3.6.0.min.js"></script>
    <script src="https://cdn.bootcss.com/axios/0.18.0/axios.min.js"></script>
    <script src="/../static/layui/layui.js"></script>
    <script>
        function remove(id) {
            console.log(id);
            layer.confirm('确定删除用户吗？', { icon: 3, title: '提示' }, function (index) {
                axios({
                    method: 'post',
                    url: '/surveyp/remove',
                    data: {
                        removeId: id
                    }
                }).then(function (response) {
                    // axios工具下，服务器真正返回的数据在返回对象的data中
                    var res = response.data;
                    if (res.code === 200) {
                        window.location.href = '/root/unpublish';
                    }
                })
                layer.close(index);

            });
        }
    </script>

</body>
</html>